/**
 * Author: Dmitry Ustimov
 * Date: 5/31/13
 * Time: 8:13 PM
 */

package com.gmail.dmitryustimov.ms.java7.mediator.mod.work.demo.col10event10;

import com.gmail.dmitryustimov.ms.java7.patternslib.mediator.Colleague;
import com.gmail.dmitryustimov.ms.java7.patternslib.mediator.SubscriberAction;

import java.math.BigDecimal;

public class ConcreteColleague6 extends AbstractColleague {

    private Mediator mediator;
    private BigDecimal sum = BigDecimal.valueOf(0);

    public ConcreteColleague6(String name, Mediator mediator) {
        this.name = name;
        this.mediator = mediator;
        this.mediator.getEvent1Publisher().subscribe(this.new Event1Action());
        this.mediator.getEvent2Publisher().subscribe(this.new Event2Action());
        this.mediator.getEvent3Publisher().subscribe(this.new Event3Action());
        this.mediator.getEvent4Publisher().subscribe(this.new Event4Action());
        this.mediator.getEvent5Publisher().subscribe(this.new Event5Action());
        this.mediator.getEvent6Publisher().subscribe(this.new Event6Action());
        this.mediator.getEvent7Publisher().subscribe(this.new Event7Action());
        this.mediator.getEvent8Publisher().subscribe(this.new Event8Action());
        this.mediator.getEvent9Publisher().subscribe(this.new Event9Action());
        this.mediator.getEvent10Publisher().subscribe(this.new Event10Action());
    }

    public void makeEvent() {
        event1Publisher.publish(new Event1("C6E1"), this);
        event2Publisher.publish(new Event2("C6E2"), this);
        event3Publisher.publish(new Event3("C6E3"), this);
        event4Publisher.publish(new Event4("C6E4"), this);
        event5Publisher.publish(new Event5("C6E5"), this);
        event6Publisher.publish(new Event6("C6E6"), this);
        event7Publisher.publish(new Event7("C6E7"), this);
        event8Publisher.publish(new Event8("C6E8"), this);
        event9Publisher.publish(new Event9("C6E9"), this);
        event10Publisher.publish(new Event10("C6E10"), this);
    }

    private class Event1Action extends SubscriberAction<Event1> {
        public Event1Action() {
            super(ConcreteColleague6.this);
        }

        @Override
        public void process(Event1 event, Colleague originator) {
            sum.add(BigDecimal.valueOf(1));
        }
    }

    private class Event2Action extends SubscriberAction<Event2> {
        public Event2Action() {
            super(ConcreteColleague6.this);
        }

        @Override
        public void process(Event2 event, Colleague originator) {
            sum.add(BigDecimal.valueOf(2));
        }
    }

    private class Event3Action extends SubscriberAction<Event3> {
        public Event3Action() {
            super(ConcreteColleague6.this);
        }

        @Override
        public void process(Event3 event, Colleague originator) {
            sum.add(BigDecimal.valueOf(3));
        }
    }

    private class Event4Action extends SubscriberAction<Event4> {
        public Event4Action() {
            super(ConcreteColleague6.this);
        }

        @Override
        public void process(Event4 event, Colleague originator) {
            sum.add(BigDecimal.valueOf(4));
        }
    }

    private class Event5Action extends SubscriberAction<Event5> {
        public Event5Action() {
            super(ConcreteColleague6.this);
        }

        @Override
        public void process(Event5 event, Colleague originator) {
            sum.add(BigDecimal.valueOf(5));
        }
    }

    private class Event6Action extends SubscriberAction<Event6> {
        public Event6Action() {
            super(ConcreteColleague6.this);
        }

        @Override
        public void process(Event6 event, Colleague originator) {
            sum.add(BigDecimal.valueOf(6));
        }
    }

    private class Event7Action extends SubscriberAction<Event7> {
        public Event7Action() {
            super(ConcreteColleague6.this);
        }

        @Override
        public void process(Event7 event, Colleague originator) {
            sum.add(BigDecimal.valueOf(7));
        }
    }

    private class Event8Action extends SubscriberAction<Event8> {
        public Event8Action() {
            super(ConcreteColleague6.this);
        }

        @Override
        public void process(Event8 event, Colleague originator) {
            sum.add(BigDecimal.valueOf(8));
        }
    }

    private class Event9Action extends SubscriberAction<Event9> {
        public Event9Action() {
            super(ConcreteColleague6.this);
        }

        @Override
        public void process(Event9 event, Colleague originator) {
            sum.add(BigDecimal.valueOf(9));
        }
    }

    private class Event10Action extends SubscriberAction<Event10> {
        public Event10Action() {
            super(ConcreteColleague6.this);
        }

        @Override
        public void process(Event10 event, Colleague originator) {
            sum.add(BigDecimal.valueOf(10));
        }
    }
}
